package com.tgy.myplus.基础学习.Thread.Normal;

public class TicketThread implements Runnable{
    //票数
    private int ticketNums =10;
    @Override
    public void run() {
        while (true){
            if (ticketNums <=0){
                break;
            }
            try{
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"---->拿到了第"+ ticketNums-- +"张票");
        }
    }

    public static void main(String[] args) {
        TicketThread ticketThread = new TicketThread();

        new Thread(ticketThread,"一号线程").start();
        new Thread(ticketThread,"二号线程").start();
        new Thread(ticketThread,"三号线程").start();
        new Thread(ticketThread,"四号线程").start();
        new Thread(ticketThread,"五号线程").start();
    }
}
